package com.aaa.cars.controller;

import com.aaa.cars.util.Upload;
import com.aaa.common.constants.ReturnStatus;
import com.aaa.common.util.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("upload")
public class UploadController {
    @Resource
    private Upload upload;

    @PostMapping("uploadImg")
    public Result uploadImg(MultipartFile file) {
        System.out.println(new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(),
                this.upload.uploadImg(file))+"+++++++++++++++++++++++++++++");
        return new Result(ReturnStatus.SUCCESS.getReturnCode(),
                ReturnStatus.SUCCESS.getReturnMsg(),
                this.upload.uploadImg(file));
    }
}
